#include <iostream>
#include "DemoConsole.h"
#include "TgaBuffer.h"
#include "VertexProcessor.h"
#include "../Raycaster/Triangle.h"

namespace MASGK
{

	CDemoConsole::CDemoConsole(void)
	{
        m_TranslateLight = 0.0f;
        m_RotateCube = 0.0f;
	}


	CDemoConsole::~CDemoConsole(void)
	{
	}

	void CDemoConsole::Start()
	{
		std::cout << std::endl << "Rasterizer DEMO CONSOLE";
		CRasterizer *rasterizer = new CRasterizer();
		CObjParser *parserObj = new CObjParser();
		CMesh **objects = new CMesh*[6];
		objects[0] = new CMesh(parserObj->ParseObj("sphere.obj"));
		parserObj->Clear();
		objects[1] = new CMesh(parserObj->ParseObj("cube.obj"));
		parserObj->Clear();
		objects[2] = new CMesh(parserObj->ParseObj("cone.obj"));
		parserObj->Clear();
		objects[3] = new CMesh(parserObj->ParseObj("sphere.obj"));
		parserObj->Clear();
		objects[4] = new CMesh(parserObj->ParseObj("sphere.obj"));
		parserObj->Clear();
		objects[5] = new CMesh(parserObj->ParseObj("cylinder.obj"));
		parserObj->Clear();
		objects[6] = new CMesh(parserObj->ParseObj("cube.obj"));
		parserObj->Clear();
		CMesh ** currentObject = objects;

		rasterizer->m_Vp = new CVertexProcessor();

		rasterizer->m_Vp->SetPerspective(60.0f, rasterizer->m_RcWidth / rasterizer->m_RcHeight, 1.0f, 1000.0f);
		rasterizer->m_Vp->SetLookAt(float3(0, 0, -1.0f), float3(0, 0, 0), float3(0, 1.0f, 0));


		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByRotation(40.0f, float3(0, 1.0f, 0));
		//rasterizer->m_Vp->MultByRotation(20.0f, float3(1.0f, 0, 0));
		//rasterizer->m_Vp->MultByTranslation(float3(-1.0f, -1.0f, 0));
		rasterizer->m_Vp->CreateView();

		CTriangle *triangle = (objects[0])->GetTriangles();

		for (int i = 0; i < (objects[0])->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),		// C
					color(0.1f, 0.2f, 0.2f)
				);
		}

		// LIGHT OBJECT (for visualisation)
		float3 *lightPos = rasterizer->m_Vp->m_PointLight.GetPosition();
		float3 LightTrianglePointA = float3((*lightPos).x - 0.05f, (*lightPos).y, (*lightPos).z);
		float3 LightTrianglePointB = float3((*lightPos).x + 0.05f, (*lightPos).y, (*lightPos).z);
		float3 LightTrianglePointC = float3((*lightPos).x, (*lightPos).y + 0.1f, (*lightPos).z);

		rasterizer->m_Vp->ResetModelMatrix();
		//rasterizer->m_Vp->MultByScale(float3(0.2f, 0.2f, 1.0f));
		rasterizer->m_Vp->CreateView();
		rasterizer->Triangle
			(
				rasterizer->m_Vp->Tr(LightTrianglePointA),		// A
				rasterizer->m_Vp->Tr(LightTrianglePointB),		// B
				rasterizer->m_Vp->Tr(LightTrianglePointC),		// C
				color(1.0f, 1.0f, 1.0f)
			);
		// LIGHT OBJECT END

/*		DEMO SCENE
		// ---------------------------
		// Object 1 - Sphere

		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByTranslation(float3(-1.6f, 0, -2.0f));
		rasterizer->m_Vp->CreateView();

		CTriangle *triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(0.0f, 0.7f, 1.0f)
				);
		}
		
		currentObject++;

		// ---------------------------
		// Object 2 - Cube

		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByRotation(60.0f, float3(0, 1.0f, 0));
		rasterizer->m_Vp->MultByTranslation(float3(-0.4f, -0.7f, -2.0f));
		rasterizer->m_Vp->CreateView();

		triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(0.4f, 0.7f, 0.2f)
				);
		}

		currentObject++;

		// ---------------------------
		// Object 3 - Cone

		rasterizer->m_Vp->ResetModelMatrix();
		//rasterizer->m_Vp->MultByRotation(60.0f, float3(0, 1.0f, 0));
		rasterizer->m_Vp->MultByTranslation(float3(3.7f, 0, -1.0f));
		rasterizer->m_Vp->MultByScale(float3(.3f, 0.3f, 0.3f));
		rasterizer->m_Vp->CreateView();

		triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(0.7f, 0.7f, 0.1f)
				);
		}

		currentObject++;

		// ---------------------------
		// Object 4 - Sphere

		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByTranslation(float3(-1.0f, -7.0f, 0.0f));
		rasterizer->m_Vp->MultByScale(float3(0.17f, 0.17f, 0.17f));
		rasterizer->m_Vp->CreateView();

		triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(1.0f, 0.0f, 0.4f)
				);
		}

		currentObject++;

		// ---------------------------
		// Object 5 - Sphere

		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByTranslation(float3(3.0f, -31.0f, 0.0f));
		rasterizer->m_Vp->MultByScale(float3(0.04f, 0.04f, 0.04f));
		rasterizer->m_Vp->CreateView();

		triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(0.1f, 0.7f, 0.5f)
				);
		}

		currentObject++;

		// ---------------------------
		// Object 6 - Cylinder

		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByRotation(90.0f, float3(0, 0, 1.0f));
		rasterizer->m_Vp->MultByRotation(-10.0f, float3(0, 1.0f, 0));
		rasterizer->m_Vp->MultByTranslation(float3(2.4f, 0, -15.0f));
		rasterizer->m_Vp->MultByScale(float3(4.7f, 0.7f, 1.0f));
		rasterizer->m_Vp->CreateView();

		triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(0.3f, 0.9f, 0.3f)
				);
		}

		currentObject++;

		// ---------------------------
		// Object 7 - Cube

		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByTranslation(float3(-4.0f, -0.7f, -10.0f));
		rasterizer->m_Vp->MultByRotation(-40.0f, float3(0, 1.0f, 0));
		rasterizer->m_Vp->MultByScale(float3(1.7f, 1.7f, 1.0f));
		rasterizer->m_Vp->CreateView();

		triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(1.0f, 0.4f, 0.0f)
				);
		}
*/
		rasterizer->Save();
		delete rasterizer;
	}


	void CDemoConsole::GUIStart()
	{
		m_Rasterizer = new CRasterizer();
		m_ObjParser = new CObjParser();
		m_Objects = new CMesh*[6];
        m_Objects[0] = new CMesh(m_ObjParser->ParseObj("D:\\Programming\\OpenGL\\Projects\\Renderer\\KRenderer\\KRenderer\\krenderer\\RasterizerGUI2\\RasterizerGUI\\sphere.obj"));
		m_ObjParser->Clear();
        m_Objects[1] = new CMesh(m_ObjParser->ParseObj("D:\\Programming\\OpenGL\\Projects\\Renderer\\KRenderer\\KRenderer\\krenderer\\RasterizerGUI2\\RasterizerGUI\\cube.obj"));
		m_ObjParser->Clear();
        m_Objects[2] = new CMesh(m_ObjParser->ParseObj("D:\\Programming\\OpenGL\\Projects\\Renderer\\KRenderer\\KRenderer\\krenderer\\RasterizerGUI2\\RasterizerGUI\\cone.obj"));
		m_ObjParser->Clear();
        m_Objects[3] = new CMesh(m_ObjParser->ParseObj("D:\\Programming\\OpenGL\\Projects\\Renderer\\KRenderer\\KRenderer\\krenderer\\RasterizerGUI2\\RasterizerGUI\\sphere.obj"));
		m_ObjParser->Clear();
        m_Objects[4] = new CMesh(m_ObjParser->ParseObj("D:\\Programming\\OpenGL\\Projects\\Renderer\\KRenderer\\KRenderer\\krenderer\\RasterizerGUI2\\RasterizerGUI\\sphere.obj"));
		m_ObjParser->Clear();
        m_Objects[5] = new CMesh(m_ObjParser->ParseObj("D:\\Programming\\OpenGL\\Projects\\Renderer\\KRenderer\\KRenderer\\krenderer\\RasterizerGUI2\\RasterizerGUI\\cylinder.obj"));
		m_ObjParser->Clear();
        m_Objects[6] = new CMesh(m_ObjParser->ParseObj("D:\\Programming\\OpenGL\\Projects\\Renderer\\KRenderer\\KRenderer\\krenderer\\RasterizerGUI2\\RasterizerGUI\\cube.obj"));
		m_ObjParser->Clear();
		m_Object = m_Objects;

		m_Rasterizer->m_Vp = new CVertexProcessor();

		

	}

    uint** CDemoConsole::Render(short _scene)
	{
		m_Rasterizer->m_Vp->SetPerspective(60.0f, m_Rasterizer->m_RcWidth / m_Rasterizer->m_RcHeight, 1.0f, 1000.0f);
		m_Rasterizer->m_Vp->SetLookAt(float3(0, 0, -1.0f), float3(0, 0, 0), float3(0, 1.0f, 0));

        // Clear color buffor
        m_Rasterizer->GetBuffor()->Clear(float3());

        switch(_scene)
        {
            case 0:
                RenderScene0();
            break;

            case 1:
                RenderScene1();
            break;

            case 2:
                RenderScene2();
            break;
        }



		return m_Rasterizer->GetColorBuffer();
	}

    void CDemoConsole::RenderScene0()
    {
        m_Rasterizer->m_Vp->ResetModelMatrix();
        m_Rasterizer->m_Vp->MultByRotation(40.0f, float3(0, 1.0f, 0));
        m_Rasterizer->m_Vp->MultByRotation(sin(m_TranslateLight) * 360.0f, float3(0, 1.0f, 0));
        //m_Rasterizer->m_Vp->MultByRotation(20.0f, float3(1.0f, 0, 0));
        //m_Rasterizer->m_Vp->MultByTranslation(float3(-1.0f, -1.0f, 0));
        m_Rasterizer->m_Vp->CreateView();

        CTriangle *triangle = (m_Object[0])->GetTriangles();

        for (int i = 0; i < (m_Object[0])->m_Triangles; i++, triangle++)
        {
            m_Rasterizer->Triangle
                (
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),		// C
                    color(0.1f, 0.2f, 0.2f)
                );
        }

        // LIGHT OBJECT (for visualisation)
        float3 *lightPos = m_Rasterizer->m_Vp->m_PointLight.GetPosition();
        float3 LightTrianglePointA = float3((*lightPos).x - 0.05f, (*lightPos).y, (*lightPos).z);
        float3 LightTrianglePointB = float3((*lightPos).x + 0.05f, (*lightPos).y, (*lightPos).z);
        float3 LightTrianglePointC = float3((*lightPos).x, (*lightPos).y + 0.1f, (*lightPos).z);

        m_TranslateLight += 0.001f;
        m_Rasterizer->m_Vp->m_PointLight.SetPosition(float3(sin(m_TranslateLight), (*lightPos).y,(*lightPos).z));

        m_Rasterizer->m_Vp->ResetModelMatrix();
        //m_Rasterizer->m_Vp->MultByScale(float3(0.2f, 0.2f, 1.0f));
        m_Rasterizer->m_Vp->MultByTranslation(float3(sin(m_TranslateLight), 0, 0));
        m_Rasterizer->m_Vp->CreateView();
        m_Rasterizer->Triangle
            (
                m_Rasterizer->m_Vp->Tr(LightTrianglePointA),		// A
                m_Rasterizer->m_Vp->Tr(LightTrianglePointB),		// B
                m_Rasterizer->m_Vp->Tr(LightTrianglePointC),		// C
                color(1.0f, 1.0f, 1.0f)
            );
        // LIGHT OBJECT END
    }
	
    void CDemoConsole::RenderScene1()
    {
        m_RotateCube += 0.3f;

        if (m_RotateCube > 360.0f)
            m_RotateCube = 0.0f;

        m_Rasterizer->m_Vp->ResetModelMatrix();
        m_Rasterizer->m_Vp->MultByTranslation(float3(-0.5f, -0.5f, 0.0f));
        m_Rasterizer->m_Vp->MultByRotation(m_RotateCube, float3(0, 1.0f, 0));
        m_Rasterizer->m_Vp->MultByTranslation(float3(0.5f, 0.5f, 0.0f));

        m_Rasterizer->m_Vp->CreateView();

        CTriangle *triangle = (m_Object[1])->GetTriangles();

        for (int i = 0; i < (m_Object[1])->m_Triangles; i++, triangle++)
        {
            m_Rasterizer->Triangle
                (
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),		// C
                    color(0.1f, 0.4f, 0.1f)
                );
        }

        // Light
        float3 *lightPos = m_Rasterizer->m_Vp->m_PointLight.GetPosition();
        m_Rasterizer->m_Vp->m_PointLight.SetPosition(float3(-1.0f, (*lightPos).y,(*lightPos).z));
    }

    void CDemoConsole::RenderScene2()
    {
        // Light
        m_Rasterizer->m_Vp->m_PointLight.SetPosition(float3(-4.0f, -1.0f, -2.0f));

        // ---------------------------
        // Object 1 - Sphere

        m_Rasterizer->m_Vp->ResetModelMatrix();
        m_Rasterizer->m_Vp->MultByTranslation(float3(-1.6f, -1.4f, -2.0f));
        m_Rasterizer->m_Vp->CreateView();

        CTriangle *triangle = (m_Object[0])->GetTriangles();

        for (int i = 0; i < (m_Object[0])->m_Triangles; i++, triangle++)
        {
            m_Rasterizer->Triangle
                (
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
                    color(0.1f, 0.5f, 1.0f)
                );
        }

        // ---------------------------
        // Object 2 - Cube

        m_Rasterizer->m_Vp->ResetModelMatrix();
        m_Rasterizer->m_Vp->MultByRotation(60.0f, float3(0, 1.0f, 0));
        m_Rasterizer->m_Vp->MultByTranslation(float3(-0.4f, -1.0f, -2.0f));
        m_Rasterizer->m_Vp->CreateView();

        triangle = (m_Object[1])->GetTriangles();

        for (int i = 0; i < (m_Object[1])->m_Triangles; i++, triangle++)
        {
            m_Rasterizer->Triangle
                (
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
                    color(0.4f, 0.6f, 0.2f)
                );
        }

        // ---------------------------
        // Object 3 - Cone

        m_Rasterizer->m_Vp->ResetModelMatrix();
        //m_Rasterizer->m_Vp->MultByRotation(60.0f, float3(0, 1.0f, 0));
        m_Rasterizer->m_Vp->MultByTranslation(float3(3.7f, -1.0f, -1.0f));
        m_Rasterizer->m_Vp->MultByScale(float3(.3f, 0.3f, 0.3f));
        m_Rasterizer->m_Vp->CreateView();

        triangle = (m_Object[2])->GetTriangles();

        for (int i = 0; i < (m_Object[2])->m_Triangles; i++, triangle++)
        {
            m_Rasterizer->Triangle
                (
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
                    color(0.5f, 0.5f, 0.1f)
                );
        }

        // ---------------------------
        // Object 4 - Sphere

        m_Rasterizer->m_Vp->ResetModelMatrix();
        m_Rasterizer->m_Vp->MultByTranslation(float3(-3.0f, 2.0f, -10.0f));
        m_Rasterizer->m_Vp->MultByScale(float3(1.3f, 1.3f, 1.0f));
        m_Rasterizer->m_Vp->CreateView();

        triangle = (m_Object[3])->GetTriangles();

        for (int i = 0; i < (m_Object[3])->m_Triangles; i++, triangle++)
        {
            m_Rasterizer->Triangle
                (
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
                    color(0.6f, 0.1f, 0.4f)
                );
        }

        // ---------------------------
        // Object 5 - Sphere

        m_Rasterizer->m_Vp->ResetModelMatrix();
        m_Rasterizer->m_Vp->MultByTranslation(float3(-1.0f, 2.0f, -11.0f));
        m_Rasterizer->m_Vp->MultByScale(float3(1.5f, 1.5f, 1.0f));
        m_Rasterizer->m_Vp->CreateView();

        triangle = (m_Object[4])->GetTriangles();

        for (int i = 0; i < (m_Object[4])->m_Triangles; i++, triangle++)
        {
            m_Rasterizer->Triangle
                (
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
                    color(0.1f, 0.5f, 0.3f)
                );
        }

        // ---------------------------
        // Object 6 - Cylinder

        m_Rasterizer->m_Vp->ResetModelMatrix();
        m_Rasterizer->m_Vp->MultByRotation(90.0f, float3(0, 0, 1.0f));
        m_Rasterizer->m_Vp->MultByRotation(-10.0f, float3(0, 1.0f, 0));
        m_Rasterizer->m_Vp->MultByTranslation(float3(2.4f, 6.0f, -15.0f));
        m_Rasterizer->m_Vp->MultByScale(float3(4.7f, 0.7f, 1.0f));
        m_Rasterizer->m_Vp->CreateView();

        triangle = (m_Object[5])->GetTriangles();

        for (int i = 0; i < (m_Object[5])->m_Triangles; i++, triangle++)
        {
            m_Rasterizer->Triangle
                (
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
                    color(0.3f, 0.5f, 0.3f)
                );
        }

        // ---------------------------
        // Object 7 - Cube

        m_Rasterizer->m_Vp->ResetModelMatrix();
        m_Rasterizer->m_Vp->MultByTranslation(float3(0.0f, 0.0f, -2.4f));
        m_Rasterizer->m_Vp->MultByRotation(-40.0f, float3(0, 1.0f, 0));

        m_Rasterizer->m_Vp->CreateView();

        triangle = (m_Object[6])->GetTriangles();

        for (int i = 0; i < (m_Object[6])->m_Triangles; i++, triangle++)
        {
            m_Rasterizer->Triangle
                (
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
                    m_Rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
                    color(0.7f, 0.4f, 0.1f)
                );
        }
    }
}

		// ---------------------------
		// Object 1 - Sphere
/*
		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByTranslation(float3(-1.6f, -1.4f, -2.0f));
		rasterizer->m_Vp->CreateView();

		CTriangle *triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(0.0f, 0.7f, 1.0f)
				);
		}
		
		currentObject++;

		// ---------------------------
		// Object 2 - Cube

		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByRotation(60.0f, float3(0, 1.0f, 0));
		rasterizer->m_Vp->MultByTranslation(float3(-0.4f, -1.0f, -2.0f));
		rasterizer->m_Vp->CreateView();

		triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(0.4f, 0.7f, 0.2f)
				);
		}

		currentObject++;

		// ---------------------------
		// Object 3 - Cone

		rasterizer->m_Vp->ResetModelMatrix();
		//rasterizer->m_Vp->MultByRotation(60.0f, float3(0, 1.0f, 0));
		rasterizer->m_Vp->MultByTranslation(float3(3.7f, -1.0f, -1.0f));
		rasterizer->m_Vp->MultByScale(float3(.3f, 0.3f, 0.3f));
		rasterizer->m_Vp->CreateView();

		triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(0.7f, 0.7f, 0.1f)
				);
		}

		currentObject++;

		// ---------------------------
		// Object 4 - Sphere

		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByTranslation(float3(-3.0f, 2.0f, -10.0f));
		rasterizer->m_Vp->MultByScale(float3(1.3f, 1.3f, 1.0f));
		rasterizer->m_Vp->CreateView();

		triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(1.0f, 0.0f, 0.4f)
				);
		}

		currentObject++;

		// ---------------------------
		// Object 5 - Sphere

		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByTranslation(float3(-1.0f, 2.0f, -11.0f));
		rasterizer->m_Vp->MultByScale(float3(1.5f, 1.5f, 1.0f));
		rasterizer->m_Vp->CreateView();

		triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(0.1f, 0.7f, 0.5f)
				);
		}

		currentObject++;

		// ---------------------------
		// Object 6 - Cylinder

		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByRotation(90.0f, float3(0, 0, 1.0f));
		rasterizer->m_Vp->MultByRotation(-10.0f, float3(0, 1.0f, 0));
		rasterizer->m_Vp->MultByTranslation(float3(2.4f, 6.0f, -15.0f));
		rasterizer->m_Vp->MultByScale(float3(4.7f, 0.7f, 1.0f));
		rasterizer->m_Vp->CreateView();

		triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(0.3f, 0.9f, 0.3f)
				);
		}

		currentObject++;

		// ---------------------------
		// Object 7 - Cube

		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByTranslation(float3(0.0f, 0.0f, -2.4f));
		rasterizer->m_Vp->MultByRotation(-40.0f, float3(0, 1.0f, 0));
		
		rasterizer->m_Vp->CreateView();

		triangle = (*currentObject)->GetTriangles();

		for (int i = 0; i < (*currentObject)->m_Triangles; i++, triangle++)
		{
			rasterizer->Triangle
				(
					rasterizer->m_Vp->Tr(float3(triangle->GetA()->GetX(), triangle->GetA()->GetY(), triangle->GetA()->GetZ())),		// A
					rasterizer->m_Vp->Tr(float3(triangle->GetB()->GetX(), triangle->GetB()->GetY(), triangle->GetB()->GetZ())),		// B
					rasterizer->m_Vp->Tr(float3(triangle->GetC()->GetX(), triangle->GetC()->GetY(), triangle->GetC()->GetZ())),			// C
					color(1.0f, 0.4f, 0.0f)
				);
		}
*/

			/*
		rasterizer->m_Vp->MultByTranslation(float3(1.0f, 0.0f, 0.0f));
		rasterizer->m_Vp->MultByRotation(-30.0f, float3(0, 1.0f, 0));
		rasterizer->m_Vp->MultByTranslation(float3(-1.0f, 0.0f, 0.0f));
		//rasterizer->m_Vp->MultByScale(float3(2.0, 1.0f, 1.0f));
		rasterizer->m_Vp->CreateView();

		rasterizer->Triangle
			(
				rasterizer->m_Vp->Tr(float3(-1.5f, -0.33f, 0.0f)),		// A
				rasterizer->m_Vp->Tr(float3(-0.5f, -0.33f, 0.0f)),		// B
				rasterizer->m_Vp->Tr(float3(-1.0f, 0.66f, 0.0f)),		// C
				color(0.0f, 0.0f, 0.0f)
			);

		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->CreateView();

		rasterizer->Triangle
			(
				rasterizer->m_Vp->Tr(float3(-0.5f, -0.33f, 0.0f)),		// A
				rasterizer->m_Vp->Tr(float3(0.5f, -0.33f, 0.0f)),		// B
				rasterizer->m_Vp->Tr(float3(0.0f, 0.66f, 0.0f)),			// C
				color(0.0f, 0.0f, 0.0f)
			);

		rasterizer->m_Vp->ResetModelMatrix();
		rasterizer->m_Vp->MultByTranslation(float3(-1.0f, 0.0f, 0.0f));
		rasterizer->m_Vp->MultByRotation(30.0f, float3(0, 1.0f, 0));
		rasterizer->m_Vp->MultByTranslation(float3(1.0f, 0.0f, 0.0f));
		rasterizer->m_Vp->CreateView();

		rasterizer->Triangle
			(
				rasterizer->m_Vp->Tr(float3(0.5f, -0.33f, 0.0f)),		// A
				rasterizer->m_Vp->Tr(float3(1.5f, -0.33f, 0.0f)),		// B
				rasterizer->m_Vp->Tr(float3(1.0f, 0.66f, 0.0f)),			// C
				color(0.0f, 0.0f, 0.0f)
			);
		*/
